a = 1


def outer_fun():
    def fun():
        nonlocal a  # a in outer_fun function
        print(f'fun a:{a}')

    a = 2
    fun()


def outer2():
    count = 10

    def inner():
        # count = 20
        nonlocal count  # SyntaxError: name 'count' is assigned to before nonlocal declaration
        print(f'nonlocal count:{count}')

    inner()
    print(f'outer2 count:{count}')


if __name__ == '__main__':
    outer_fun()  # fun a:2
    outer2()
